<script setup lang='ts'>
import mButton from "../../components/m-button.vue"
const connectedWallet = () => {
  if (typeof window.ethereum !== 'undefined') {
    console.log('MetaMask is installed!')
    window.ethereum.request({ method: 'eth_requestAccounts' })
      .then((accounts: any) => {
        uni.showToast({
          title: `已连接钱包:${accounts.join()}`,
          icon:"none"
        })
      })
      .catch((error: any) => {
        console.error(error)
      })
  } else {
    console.log('MetaMask is not installed!')
  }
}
</script>
<template>
  <mButton @click="connectedWallet">连接钱包</mButton>
</template>
